<!-- Study_FreeCourseRichtextNew.html -->
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>描述</title>
		<link rel="stylesheet" type="text/css" href="../../css/api.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/base.css">
		<style type="text/css">
			body {
				background-color: #FFFFFF
			}
			.content_text {
				word-break: break-all;
				word-wrap: break-word;
				/*text-align:left;*/
				padding: 10px;
				padding-bottom: 50px;
			}
			/*#richTextContent p:nth-child(1){
			 text-indent: 2em;
			 }*/
			.content_title {
				word-break: break-all;
				word-wrap: break-word;
				text-align: center;
				padding: 10px;
			}
			table {
				border: 1px solid #ccc;
				border-collapse: collapse;
				border-spacing: 0;
			}
			td, th {
				border: 1px solid #ccc;
				padding: 0;
			}
			ul li {
				list-style: disc;
			}
			ol li {
				list-style: decimal;
			}
			.white_div {
				background-color: white;
				height: 1px;
			}
			.butom {
				margin-top: 5px;
				width: 100%;
				padding-top: 15px;
				padding-bottom: 15px;
				font-size: 18px;
				display: block;
				color: #fff;
				/*	border: 1px solid #18b4ed;*/
				background-color: #ff9900;
			}
			.but_bottom {
				bottom: 0px;
				width: 100%;
				position: fixed;
				/*padding-left: 10px;
				 padding-right: 10px;*/
				text-align: center;
			}
			p {
				color: #6;
				/*font-size: 14px;*/
			}
		</style>
	</head>
	<body>
		<div style="margin-right: 10px;margin-left: 10px;padding-top:10px;height: 200px"  class="base_none_item " id="voide" onclick="toPlayVideo()">
			<img src="../../image/img_voide.png" style="width: 100%;height: 100%;" />
		</div>
		<div class="content_text" id="richTextContent"></div>
		<div class="but_bottom " hidden="hidden">
			<div id="sumbit_bt" type="button" class="butom" onclick="pushToNextWindow()">
				开始授课
			</div>
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/common.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/getToken.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript">
		var url = "";
		var pageParam = "";
		var cType = "";
		var type = '';
		//角色类型  0：学生  1老师
		//视频地址
		apiready = function() {
			loadData();
		}
		function loadData() {
			pageParam = api.pageParam;
			settype();
			url = pageParam.path;
			if (url != "" && url != null && url != undefined) {
				$("#voide").show();
			}
			var bewrite = api.pageParam.bewrite;
			//			alert(bewrite);
			setupRichText(api.pageParam.bewrite);
		}

		function settype() {
			cType = pageParam.content_type;
			type = $api.getStorage('cfnetSelectType');
			if (cType == 'hdresource' || cType == 'richtext' || cType == 'hdresource') {//互动资源
				if (type == 0) {//展现学生端4个功能按钮
					$('#sumbit_bt').text("开始学习");
				}
				$('.but_bottom').show();
			} else if (cType == 'sitenow') {
				if (type == 0) {//展现学生端4个功能按钮
					$('#sumbit_bt').text("开始评分");
					requestStartOrEndState();
				}
				$('.but_bottom').show();
			} else if (cType == 'survey') {//调查
				if (type == 0) {//展现学生端4个功能按钮
					$('#sumbit_bt').text("开始调查");
				}
				$('.but_bottom').show();
			} else if (cType == 'tests') {//测验
				if (type == 0) {//展现学生端4个功能按钮
					$('#sumbit_bt').text("进入测验");
				}
				$('.but_bottom').show();
			}
		}

		function setupRichText(other) {
			other = other.replace(/\+/g, " ");
			var newWidth = api.winWidth - 10;
			other = other.replace("width:420;", "width='" + newWidth + "'");
			other = other.replace("width:640;", "width='" + newWidth + "'");
			other = other.replace('width="518"', "width='" + newWidth + "'");
			other = other.replace("src=\"/public", "src=\"http://cfnet.org.cn/public");
			$api.html($api.byId('richTextContent'), other);
			imageTapToSee();
			setupImage();
		}

		function setupImage() {
			var newWidth = api.winWidth - 20;
			$("img").each(function(i) {
				var oldWith = $(this).width();
				if (oldWith == 0) {
					setTimeout(function() {
						setupImage();
					}, 500);
					return;
				}
				if (oldWith > newWidth) {
					var oldHeight = $(this).height();
					var newHeight = oldHeight * (newWidth / oldWith);
					$(this).width(newWidth);
					$(this).height(newHeight);
				}
			});
		}

		/* is_encr是否加密传 1/0  1是加密0是未加密
		 baidu_cloud_id_url 加密后地址，没有传空串
		 path 原始路径
		 title 视频标题*/
		function toPlayVideo() {
			pushToBaiDuPlayer(0, "", url, api.pageParam.cdetailtitle);
			//			var videoPlayer = api.require('videoPlayer');
			//			videoPlayer.play({
			//				path : url,
			//				texts : {
			//					head : {
			//						title : api.pageParam.cdetailtitle
			//					}
			//				},
			//				styles : {
			//					head : {
			//						backSize : 24,
			//						backImg : 'widget://image/vp_back.png',
			//						setSize : 24,
			//						setImg : 'widget://image/vp_more.png'
			//					},
			//					foot : {
			//						playSize : 24,
			//						playImg : 'widget://image/vp_play.png',
			//						pauseImg : 'widget://image/vp_pause.png',
			//						nextSize : 24,
			//						nextImg : 'widget://image/vp_next.png'
			//					}
			//				}
			//			}, function(ret, err) {
			//			});
		}

		//根据类型跳转页面
		function pushToNextWindow() {
			var winName = "";
			if (cType == 'richtext') {//富文本
				var connectionType = api.connectionType;
				if (connectionType != 'wifi' && connectionType != 'none') {
					api.confirm({
						title : '提示',
						msg : '您当前处于移动数据网络下，是否继续播放',
						buttons : ['确定', '取消']
					}, function(ret, err) {
						var index = ret.buttonIndex;
						if (index == 1) {//确定
							url = pageParam.rid;
							toPlayVideo();
						}
					});
				} else {
					url = pageParam.rid;
					toPlayVideo();
				}
				return;
			} else if (cType == 'sitenow') {//现场实操
				winName = 'new_Mark_sheet';
			} else if (cType == 'hdresource') {//互动资源
				winName = 'student_study_freecourse_interactiveNew';
			}
			if (type == 0) {//学生端
				if (cType == 'survey') {//调查
					winName = 'New_Student_Study_ResearchExam';
				} else if (cType == 'tests') {//测验
					winName = 'New_student_study_freecourse_TestExam';
				} else if (cType == 'sitenow') {
					winName = 'new_Mark_sheet';
				}
			} else {//教师端
				if (cType == 'survey') {//调查
					winName = '../Teacher_Teach/Teacher_Freecourse_ResearchChapter';
					api.openWin({useWKWebView:true,
						name : 'Teacher_Freecourse_ResearchChapter',
						url : winName + '.html',
						pageParam : pageParam,
						slidBackEnabled : false
					});
					return;
				} else if (cType == 'tests') {//测验
					winName = '../Teacher_Teach/Teacher_Freecourse_TestChapter';
					api.openWin({useWKWebView:true,
						name : 'Teacher_Freecourse_TestChapter',
						url : winName + '.html',
						pageParam : pageParam,
						slidBackEnabled : false
					});
					return;
				} else if (cType == 'sitenow') {
					api.openWin({useWKWebView:true,
						name : 'new_Mark_sheetTea',
						url : '../LivePracticeTea/new_Mark_sheetTea.html',
						pageParam : pageParam,
						slidBackEnabled : false,
					});
					return;
				}
			}
			api.openWin({useWKWebView:true,
				name : winName,
				url : winName + '.html',
				pageParam : pageParam,
				slidBackEnabled : false,
			});
			//			api.closeWin({
			//          });
		}

		function imageTapToSee() {
			$('#richTextContent img').on('click', function() {
				showimg([$(this).attr("src")], 0);
			});
		}

		function requestStartOrEndState() {
			var params = {
				vid : pageParam.id,
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				pid : pageParam.pid,
				cid : pageParam.cid,
			};
			// alert(JSON.stringify(params));
			//var url_cf = "http://base.cfnet.org.cn/course/Sitenow_Normal/getSitenowRealdScore";
			cfnetppPOST(url_getSitenowRealdScore, params, true, function(data, status) {
				api.hideProgress();
				if (status == 'success') {
					if (data.code == 200) {
						var soure = data.data[0];
						var aaa;
						if (soure.myselfscore == "未评分" || soure.myselfscore == "") {
							aaa = 0;
						} else {
							aaa = 1;
						}
						var bbb;
						if (soure.peerscore == "未评分" || soure.peerscore == "") {
							bbb = 0;
						} else {
							bbb = 1;
						}
						var ccc;
						if (soure.teascore == "未评分" || soure.teascore == "") {
							ccc = 0;
						} else {
							ccc = 1;
						}
						if (aaa == 1 && bbb == 1 && ccc == 1) {
							$('#sumbit_bt').text("查看评分");
						}
					} else {
					}
				} else {
				}
			});
		}
	</script>
</html>
